import {mapActions} from "vuex";
import {dictCode} from "@/api/dict";

/**
*获取字典
@params:
@return:
*/
export function dictMixins(arr){
    const str = arr.join(',');
    return {
        created() {
            this.dictCode()
        },
        methods:{
            ...mapActions(['saveDict']),
            dictCode(){
                return dictCode(str).then((data = {}) => {
                  const arr = data.result || []
                    arr.forEach((item) => {
                        this.saveDict({key:item.typeNo,value:item.codeList})
                      })

                  })
            }
        },
    }
}
